<?php
declare (strict_types = 1);

namespace app\admin\middleware;

use think\facade\View;

class Check
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {

         $response = $next($request);
         if(!is_file(root_path().'app/install/data/install.lock')) return redirect('/install');
         $controller = $request->controller();
         $action = $request->action();
         $app = app('http')->getName();
         if (strtolower($action) != "login" && empty(session('admin'))) {
             return redirect('/admin/index/login');
         }
         return $response;
    }
}
